<?php 
use think\facade\Db;
 
class faceToChat{
    public function TODO($ws,$frame,$fd){
        $param = (array)json_decode($frame->data); 
        $rs = Db::name('user')->where('uuid',$param['to_uuid'])->find();
        if($rs['fd'] == ''){
             $ws->push($fd,json_encode(['status'=>0,'msg'=>'对方不在线，连接失败']) );
        }else{
            $filter = [
                "to_uuid"  => $param['to_uuid'],
                "uuid_to"  => $param['uuid_to'], 
            ];
            $toPush = [
                    'status'=>1,
                    'msg'=>'消息记录已发送',
                    'data'=>$filter, 
                    'act' => 'getFaceToCall'
                    ];
            $ws->push($rs['fd'],json_encode($toPush) );
            $pushTo = [
                'status'=>1,
                'msg'=>'消息记录已发送',
                'data'=>$filter, 
                'act' => 'faceToChat'
                ];
            $ws->push($fd,json_encode($pushTo) );
            $filter = [
                "to_uuid"  => $param['to_uuid'],
                "uuid_to"  => $param['uuid_to'], 
            ];
            
        }
         
    }
}